<template>
	<div>
		<DetailPage v-bind="BlockchainConfig" :page-row-data="props.nowRowData" :model="baseInfo" style="width: 100%; margin: 0 auto"> </DetailPage>
		<BolockChainEditRecord
			:isEncrypt="true"
			:code="props.code"
			:nowRowData="props.nowRowData"
			keyName="idCard"
			tableName="dpFoundationPractitioners"
		></BolockChainEditRecord>
	</div>
</template>

<script setup lang="ts">
import DetailPage from '@/views/aplid/DetailPage/index.vue'
import { BlockchainConfig } from './config'
import AplidPaginate from '@/components/AplidCrud/src/AplidPaginate'
import apiMod from '@/apiMod/index'
import { getAreaObj } from '@/utils/util'
import BolockChainEditRecord from '@/components/BolockChainEditRecord/index.vue'
import { xxtea_encrypt } from '@/utils/xxtea.js'

const rowData: any = inject('nowRowData')

type Props = {
	nowRowData?: any
	code?: number
	chainViewInfo?: object
	isBlockchain?: boolean
}
let props = withDefaults(defineProps<Props>(), {
	nowRowData: {},
	code: 2007,
	isBlockchain: false,
})

let baseInfo: any = ref({
	onBlockchainFlag: props.nowRowData.onBlockchainFlag,
})
const getBaseInfo = () => {
	console.log(props.nowRowData)
	let params = {
		key: xxtea_encrypt(props.nowRowData.idCard),
		code: props.code,
	}
	apiMod.view_blockchainBackupGeneral_queryBlockchainInfo(params).then((res) => {
		// 处理一下区域
		let crObj: any = getAreaObj(res.data, 'cr', 'set')
		let newObj: any = getAreaObj(res.data, '', 'set')
		let unitObj: any = getAreaObj(res.data, 'unit', 'set')
		res.data.unitAddress = unitObj.names
		res.data.crAreasName = crObj.names
		res.data.areasName = newObj.names
		baseInfo.value = res.data
		baseInfo.value.onBlockchainFlag = props.nowRowData.onBlockchainFlag
	})
}
if (props.isBlockchain) {
	baseInfo.value = props.chainViewInfo
} else {
	getBaseInfo()
}
</script>

<style lang="scss" scoped>
.record_part {
	padding: vw(20);
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	align-items: flex-start;
	.desc_part {
		width: 100%;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		.prop_part {
			margin: 10px 0;
		}
	}
	.page_part {
		align-self: flex-end;
	}
}
.time_org {
	font-family: 'Microsoft YaHei';
	font-weight: 400;
	font-size: 16px;
	text-align: left;
	color: #000;
	display: flex;
	flex-direction: row;
	justify-content: flex-start;
	align-items: center;
	.org_name {
		padding: 2px 4px;
		height: 25px;
		border-radius: 4px;
		background: #fef9eb;
		font-family: 'Microsoft YaHei';
		font-weight: 400;
		font-size: 16px;
		text-align: center;
		color: #ecbb18;
		margin-left: 39px;
	}
}
.edit_user {
	font-family: 'Microsoft YaHei Bold';
	font-weight: 700;
	font-size: 16px;
	text-align: left;
	color: #000000e6;
}
</style>
